#!/bin/sh


function run(){
	/data/oled/oled &
}
function install(){
	mkdir /data/oled
	cd /data/oled
	curl -kfsSL -O https://gitee.com/li-da-diao/oled4ax6s/releases/download/oledV1.0/oled
	echo -e "#!/bin/sh\n/data/oled/oled &\n" > /data/oled/oled.sh
	chmod +x /data/oled/oled
	chmod +x /data/oled/oled.sh

	oled_dir="/data/oled/oled.sh"
	uci set firewall.oled=include
	uci set firewall.oled.type='script'
	uci set firewall.oled.path="${oled_dir}"
	uci set firewall.oled.enabled='1'
	uci commit firewall
}

function uninstall() {
    uci delete firewall.oled
    uci commit firewall
    echo -e "\oled has been removed. \033[0m"
}

function main() {
    [ -z "$1" ] && run && return
    case "$1" in
    install)
        install
        ;;
    uninstall)
        uninstall
        ;;
    *)
        echo -e "\033[31m Unknown parameter: $1 \033[0m"
        return 1
        ;;
    esac
}
main "$@"